#coding=utf-8

from socket import *
from time import ctime

host = ''
port = 12345
BUF_SIZE = 1024
addr = (host,port)

server = socket(AF_INET,SOCK_STREAM)
server.bind(addr)
server.listen(5)

while True:
	print('waiting for connection.....')
	client_sock,client_addr = server.accept()
	print('...connected from:',client_addr)
	while True:
		data = client_sock.recv(BUF_SIZE)
		if not data:
			print('有人发了空数据')
			break
		print(data)
		client_sock.send('[%s] %s'%(ctime(),data))

	client_sock.close()

server.close()



